package com.guoliang.wechatpushing.controller;

import com.guoliang.wechatpushing.constant.Constant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.jws.WebParam;

/**
 * @author ：Leo
 * @date ：Created in 2022/10/19 14:31
 * @description：
 */
@Controller
public class ViewController {
    @Autowired
    Constant constant;
    @RequestMapping("/")
    public String index(Model model){
        model.addAttribute("count",constant.count);
        return "index";
    }
    @RequestMapping("/city")
    @ResponseBody
    public String changeCity(String province,String city,String area){
        String s=area;
        if (area==null){
            s=city;
        }
        if (s.endsWith("市")||s.endsWith("县")||s.endsWith("区")){
            s=s.substring(0,s.length()-1);
        }
        constant.city=s;
        return "success";
    }
}
